<%@ page contentType="text/html; charset=utf-8" import="com.wit.dao.impl.EmployeeDaoImpl,java.util.Map" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>员工工资</title>
<link href="../style/main.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="../css/style.css" />

<%@ taglib prefix="s" uri="/struts-tags" %>

<script>
	function changeV(objID)
	{
		if(document.getElementById("tbody_"+objID).style.display == "block")
		{
			document.getElementById("img_"+objID).src = "../images/ico_have2.gif";
			document.getElementById("tbody_"+objID).style.display = "none"
		}
		else
		{
			document.getElementById("img_"+objID).src = "../images/ico_nohave2.gif";
			document.getElementById("tbody_"+objID).style.display = "block"
		}
	}
	function submitForm()
	{
		searchWageForm.submit();
	}
	function resetForm()
	{
		searchWageForm.reset();
	}
	function startEdit()
	{
		var obj;
		var i = 0;
		while((obj = document.getElementById("chk"+i)) != null)
		{
			if(obj.checked)
			{
				document.location="wage!startEdit?wageId="+obj.value;
				return;
			}
			i++;
		}
		alert("必须选择一个工资");
	}
	function removeWage()
	{
		var obj;
		var i = 0;
		var counter = 0;
		var delObj;
		while((obj = document.getElementById("chk"+i)) != null)
		{
			if(obj.checked)
			{
				counter ++;
				delObj = obj;
			}
			i++;
		}
		if(counter == 0)
			alert("必须选择一个工资");
		else if(counter == 1)
		{
			if(confirm("确定删除？") == true)
				document.location="wage!removeWage?wageId="+delObj.value;
		}
		else
			alert("只能选择一个工资进行删除");
	}
	
	function calculateWage()
	{
		if(document.getElementById("inMonth").value.length <= 0)
		{
			alert("请选择月份");
			return;
		}	
		selectMonthForm.submit();
	}
	
	function updateBatchOfWage()
	{
		var obj;
		var i = 0;
		while((obj = document.getElementById("chk"+i)) != null)
		{
			if(obj.checked)
				break;
			i++;
		}
		if(obj == null)
		{
			alert("必须选择一个工资");
			return;
		}
		if(confirm("确定要将选中的工资标记为已结算？（结算时间将为当前时间，发放工资的值将为应发工资）") == true)
			selectWageForm.submit();
	}
	
	function updateAllWage()
	{
		if(confirm("确定要将所有工资标记为已结算？（结算时间将为当前时间，发放工资的值将为应发工资）") == true)
			document.location = "wage!updateAllWage";
	}
	
	function gotoPage(page)
	{
		if(page == 0)
		{
			searchWageForm.pageNumber.value = document.getElementById("t_pageNumber").value;
			searchWageForm.pageSize.value = document.getElementById("t_pageSize").value;
		}
		else
		{
			searchWageForm.pageNumber.value = page;
		}
		searchWageForm.submit();
	}	
</script>
<%
	Map<String,String> departmentMap = EmployeeDaoImpl.s_GetDepartmentNameMap();
	Map<String,String> positionMap = EmployeeDaoImpl.s_GetPositionNameMap();
	
	departmentMap.put("","--全部--");
	positionMap.put("","--全部--");
	request.setAttribute("departmentMap",departmentMap);
	request.setAttribute("positionMap",positionMap);
 %>
</head>
<body>
<table width="1200" align="left" cellpadding="0" cellspacing="0" class="table">
  <tr>
    <td>
      <table width="100%"  cellpadding="0" cellspacing="0" class="table2">
        <tr>
          <td valign="top">
            <table width="100%" class="top" cellpadding="0" cellspacing="0">
              <tr>
                <td>当前位置:&nbsp;工资管理&nbsp;&gt;&gt; 员工工资<a href="#"></a></td>
              </tr>
            </table>
			<div id="mainareacontent">
        <div class="mainarea">
            <div class="search">			
			  <s:form name="searchWageForm" id="searchWageForm" action="wage!showWageList" method="post" theme="simple" >
                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td height="209" class="ico" width="40px">
                            <a href="javascript:changeV(1)">
                                <img src="../images/ico_have2.gif" id="img_1" border="0" />
                            </a>
                        </td>
                      <td>
                      <table cellpadding="0" cellspacing="0" width="100%" >
                        <tr>
                          <td width="8%" height="30" align="right">&nbsp;员工编号： </td>
                          <td width="10%">
							<s:textfield name="wage.employee.employeeId" id="employeeId" />
						  </td>
                          <td width="7%" align="right">员工名称：</td>
                          <td width="20%">
							<s:textfield name="wage.employee.employeeNameC" id="employeeNameC" />
						  </td>
                          <td height="30" align="right">工资额度： </td>
                          <td><s:textfield name="wage.wageDeserved" id="wageDeserved"  cssStyle="width: 60px" />
                            至
                             <s:textfield name="wage.wageActual" id="wageActual"  cssStyle="width: 60px" />
                          </td>
                          <td width="25%">
                          	<a href="javascript:void(0);" onclick="javascript:submitForm();">
                          		<img src="../images/btn_search.gif" />
                          	</a>&nbsp;
                          	<img src="../images/btn_reset.gif" width="50" height="20" />
                          </td>
                        </tr>
                        <tbody id="tbody_1" style="display: none; border: 0px;">
                          <tr>
                            <td height="30" align="right">&nbsp;部 门： </td>
                            <td>
								<s:select list="#request.departmentMap" name="wage.employee.department.departmentId" id="departmentId"
											listKey="key" listValue="value" >
								</s:select>
							</td>
                            <td height="30" align="right">身份证号：</td>
                            <td>
								<s:textfield name="wage.employee.employeeIdcard" id="employeeIdcard" />
							</td>
                            <td width="9%" height="30" align="right">查询时间： </td>
                            <td>
							  <s:textfield name="wage.standardDate" id="standardDate"  cssStyle="width: 60px">
							  	<s:param name="value">
							  		<s:date name="wage.standardDate" format="yyyy-MM-dd" />
							  	</s:param>
							  </s:textfield>
                              至
							  <s:textfield name="wage.payDate" id="payDate"  cssStyle="width: 60px">
							  	<s:param name="value">
							  		<s:date name="wage.payDate" format="yyyy-MM-dd" />
							  	</s:param>
							  </s:textfield>
                            </td>
                            <td>&nbsp;</td>
                          </tr>
                          <tr>
                            <td height="30" align="right">职 务： </td>
                            <td>
								<s:select list="#request.positionMap" name="wage.employee.employeeposition.employeePosId" id="employeePosId" 
											listKey="key" listValue="value">
                                </s:select>
							</td>
                            <td height="30" align="right">结算状态： </td>
                            <td>
                            	<s:select list="#{'':'--全部--','true':'已结算','false':'未结算'}" name="wageState" id="wageState" 
                            				listKey="key" listValue="value">
                            	</s:select>
                            </td>
                            <td></td>
                            <td></td>
                            <td>&nbsp;</td>
                          </tr>
                          <tr>
                            <td height="30" align="right">&nbsp;工作状态： </td>
                            <td>
								<s:select list="#{'':'--全部--','在职':'在职员工','离职':'离职员工'}"
										name="wage.employee.employeeStatu" id="employeeStatu" 
										listKey="key" listValue="value">
								</s:select>
							</td>
                            <td height="30" align="right">工资卡号：</td>
                            <td>
								<s:textfield name="wage.employeeaddition.wageCard" id="wageCard" />
							</td>
                            <td></td>
                            <td></td>
                            <td>&nbsp;</td>
                          </tr>
                         </tbody>
                      </table>
                      </td>
                    </tr>
                </table>
                
                <s:hidden id="pageNumber" name="page.pageNumber"></s:hidden>
                <s:hidden id="pageSize" name="page.pageSize"></s:hidden>
			  </s:form>
            </div>
            <!----------- 数据列表 ------------------>
            <fieldset>
                    <table width="100%" cellpadding="0" cellspacing="0"class="table3">
                        <tr>
                            <td width="3%" class="title">&nbsp;</td>
                            <td width="5%" ><span class="clientinfo_but" ><a href="Wages_new.jsp">新&nbsp;增</a></span></td>
                            <td width="5%" ><span class="clientinfo_but"><a href="javascript:void(0);" onclick="javascript:startEdit();">修&nbsp;改</a></span></td>
                            <td width="5%" >
                            	<a href="javascript:void(0);" onclick="javascript:removeWage();">
                            		<img src="../images/btn_del.gif" alt="3" />
                            	</a>
                            </td>
                            <td width="5%" ><img
                                        src="../images/btn_refresh.gif" alt="3" width="50" height="20" />
                            </td>
                            <td width="12%" >&nbsp;</td>
                            <td width="5%" ><span class="clientinfo_but">导&nbsp;入</span></td>
                            <td width="5%" ><span class="clientinfo_but">导&nbsp;出</span></td>
                          
                            <td width="5%" ><span class="clientinfo_but">打&nbsp;印</span></td>
                            <td width="6%">
                            	<a href="javascript:void(0);" onclick="javascript:updateBatchOfWage();">
	                            	<span class="clientinfo_but">
	                            		结算选中
	                            	</span>
                            	</a>
                            </td>
                            <td width="6%">
                            	<a href="javascript:void(0);" onclick="javascript:updateAllWage();">
	                            	<span class="clientinfo_but">
	                            		结算全部
	                            	</span>
                            	</a>
                            </td>
                            <td width="20%">
                            	<form id="selectMonthForm" name="selectMonthForm" action="wage!addBatchOfWage" method="post">
                            		选择月份：<input type="text" id="inMonth" name="inMonth" style="border:1px" />
                            		<a href="javascript:void(0);" onclick="javascript:calculateWage();">
                            			<span class="clientinfo_but">按月计算</span>
									</a>
                            	</form>
                            </td>
                        </tr>
                    </table>
            <s:form name="selectWageForm" id="selectWageForm" action="wage!updateBatchOfWage" method="post">
            <table width="100%" cellpadding="0" cellspacing="1" class="dg_borderstyle">
              <thead>
                <tr>
                  <th width="20" height="52"> <input name="checkbox" type="checkbox" id="chk_all" onclick="docheck()" /></th>
                  <th width="55">员工编号</th>
                  <th width="55">员工姓名</th>
                  <th width="55">部门</th>
                  <th width="55">职位</th>
                  <th width="55">工作状态</th>
                  <th width="55">结算状态</th>
                  <th width="85">工资卡号</th>
                  <th width="60">应发工资</th>
                  <th width="60">实发工资</th>
                  <th width="60">工资月份</th>
                  <th width="60">基本佣金</th>
                  <th width="70">月度销售奖</th>
                  <th width="70">季度销售奖</th>
                  <th width="70">年度销售奖</th>
                  <th width="80">增员辅导津贴</th>
                  <th width="90">直辖组管理津贴</th>
                  <th width="50">育成奖</th>
                </tr>
              </thead>
              <tbody >
              	<s:iterator value="#request.wageList" status="st" id="wageList" >
	                <tr>
	                  <td>
	                  	<s:checkbox name="chks" id="%{'chk'+#st.getIndex()}" fieldValue="%{wageId}" theme="simple" />
	                  </td>
	                  <td>
	                  	<s:property value="employee.employeeId" />
	                  </td>
	                  <td>
					  	<s:property value="employee.employeeNameC" />
					  </td>
	                  <td>
					  	<s:property value="employee.department.departNameC" />
					  </td>
	                  <td>
					  	<s:property value="employee.employeeposition.positionName" />
					  </td>
	                  <td>
					  	<s:property value="employee.employeeStatu" />
					  </td>
	                  <td>
					  	<s:property value="wageState" />
					  </td>
	                  <td>
					  	<s:property value="employeeaddition.wageCard" />
					  </td>
	                  <td   >
					  	<s:property value="wageDeserved" default="0.00" />
					  </td>
	                  <td   >
					  	<s:property value="wageActual" default="0.00" />
					  </td>
	                  <td   >
					  	<s:date name="standardDate" format="yyyy-MM" />
					  </td>
	                  <td   >
					  	<s:property value="%{fyc+ryc}" default="0.00"/>
					  </td>
	                  <td   >
					  	<s:property value="monthlyAward" default="0.00"/>
					  </td>
	                  <td   >
					  	<s:property value="quarterlyAward" default="0.00" />
					  </td>
	                  <td >
					  	<s:property value="annualAward" default="0.00" />
					  </td>
	                  <td >
					  	<s:property value="zyAllowance" default="0.00" />
					  </td>
	                  <td >
					  	<s:property value="dallowance" default="0.00" />
					  </td>
	                  <td >
					  	<s:property value="ycAllowance" default="0.00" />
					  </td>
	                </tr>
                </s:iterator>
              </tbody>
            </table>
            </s:form>
            </fieldset>
            
            <table width="100%" cellpadding="0" cellspacing="0" class="dg_pagestyle">
                <tr>
                    <td class="pageinfo">
                        	第<s:property value="page.pageNumber"/>页 | 共<s:property value="page.totalPage"/>页
                    </td>
                    <td class="pagebutton">
                        每页
                        <s:select id="t_pageSize" name="page.pageSize" list="{'10','20','30','40','50'}" theme="simple">
                        </s:select>
                        条记录 | 第
                        <s:textfield id="t_pageNumber" name="page.pageNumber" cssStyle="width: 20px;" theme="simple" />
                        页
                        <a onclick="javascript:gotoPage(0);" href="javascript:void(0);">
                        	<img src="../images/btn_go.gif" />
                        </a>
                        <a onclick="javascript:gotoPage(1);" href="javascript:void(0);">
                        	<img src="../images/btn_sy.gif" width="55" height="20" />
                        </a>
                        <a onclick="javascript:gotoPage(<s:property value='page.prePage' />);" 
                        		href="javascript:void(0);">
                        	<img src="../images/btn_syy.gif" width="55" height="20" />
                        </a>
                        <a onclick="javascript:gotoPage(<s:property value='page.nextPage' />);" 
                        		href="javascript:void(0);">
                        	<img src="../images/btn_xyy.gif" width="55" height="20" />
                        </a>
                        <a onclick="javascript:gotoPage(<s:property value='page.lastPage' />);" 
                        		href="javascript:void(0);">
                        	<img src="../images/btn_wy.gif" width="55" height="20" />
                        </a>
                    </td>
                </tr>
            </table>
        </div>
      </div>          </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
